<template>
  <el-select v-model="roleId" placeholder="请选择" @change="change">
    <el-option
      v-for="item in roles"
      :key="item.id"
      :label="item.label"
      :value="item.id">
    </el-option>
  </el-select>
</template>

<script>
  import {getRoleList} from '@/api/userRole';
  export default {
    name: "index",
    model: {
      prop: 'roleId',
      event: 'cc'
    },
    props:["roleId"],
    data() {
      return {
        roles: []
      }
    },
    mounted() {
      let _this = this;
      getRoleList().then(function (data) {
        if (data.code == 200){
          _this.roles = data.data;
        } else{
          _this.$message.error(data.message);
        }
      })
    },
    methods : {
      updateParentVal(val){
        this.$emit('cc', val)
      },
      change(val){
        this.updateParentVal(val);
      }
    }
  }
</script>

<style scoped>

</style>
